package com.imooc.sell.handler;

import com.imooc.sell.conf.ProjectUrlConfig;
import com.imooc.sell.exception.SellException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.servlet.ModelAndView;

@ControllerAdvice
public class SellExceptionHandler {

    @Autowired
    private ProjectUrlConfig projectUrlConfig;

    @ExceptionHandler(value = SellException.class)
    public ModelAndView handle(){
        return new ModelAndView("redirect:".concat(projectUrlConfig.getWechatOpenAuthorize())
            .concat("/sell/wechat/qrAuthorize")
            .concat("?returnUrl=")
            .concat(projectUrlConfig.getSell())
            .concat("/sell/seller/login"));
    }
}
